home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Internet / News / Alexandra.0.82 / Source / Decoding.subproj / DecodeCell.m < prev    next >
Encoding:
Text File  |  1996-01-30  |  1.4 KB  |  85 lines

  1.  
  2. #import <appkit/appkit.h>
  3.  
  4. #import "DecodeCell.h"
  5.  
  6. static NXImage * successImage = nil;
  7. static NXImage * failImage = nil;
  8.  
  9.  
  10. @implementation DecodeCell 
  11.  
  12. + (void) initialize
  13. {
  14.     successImage = [NXImage findImageNamed:"Success.tiff"];
  15.     failImage = [NXImage findImageNamed:"Failure.tiff"];
  16. }
  17.  
  18. - init
  19. {
  20.     [super init];
  21.     articleIndex = 0;
  22.     decodeStatus = NOT_DECODED;
  23.     return self;
  24. }
  25.  
  26. - (int) articleIndex
  27. {
  28.     return articleIndex;
  29. }
  30.  
  31. - (void) setArticleIndex:(int)index
  32. {
  33.     articleIndex = index;
  34. }
  35.  
  36. - (SuccessType_t) decodeStatus
  37. {
  38.     return decodeStatus;
  39. }
  40.  
  41. - (void) setDecodeStatus:(SuccessType_t)status
  42. {
  43.     decodeStatus = status;
  44. }
  45.  
  46. - drawSelf:(const NXRect *)frameRect inView:controlView
  47. {
  48.     NXRect textRect = *frameRect;
  49.     NXImage * imageToUse = nil;
  50.     
  51.     PSsetgray(NX_LTGRAY);
  52.     NXRectFill(frameRect);
  53.     
  54.     NX_X(&textRect) += 20.0;
  55.     NX_WIDTH(&textRect) -= 20.0;
  56.     
  57.     [super drawSelf:&textRect inView:controlView];
  58.     
  59.     // Draw the correct image if one has been set.
  60.     if ([self decodeStatus] == DECODE_SUCCESSFUL) {
  61.         imageToUse = successImage;
  62.     }
  63.     else if ([self decodeStatus] == DECODE_FAILED) {
  64.         imageToUse = failImage;
  65.     }
  66.     
  67.     if (imageToUse != nil) {
  68.         NXPoint imageOrigin;
  69.         NXSize imageSize;
  70.         
  71.         [imageToUse getSize:&imageSize];
  72.         imageOrigin.x = NX_X(frameRect) + 2.0;
  73.         imageOrigin.y = NX_Y(frameRect) + NX_HEIGHT(frameRect) + 
  74.             ((NX_HEIGHT(frameRect) - imageSize.height) / 2.0);
  75.         
  76.         [imageToUse composite:NX_SOVER toPoint:&imageOrigin];
  77.     }
  78.     return self;
  79. }
  80.  
  81. @end
  82.  
  83.  
  84.  
  85.